package day1217;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class GradeTest {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        GradeDao dao = new GradeDaoImpl();
        SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-mm-dd");//可以方便地修改日期格式
        int choice = 0;
        while (true) {
            System.out.println("1.增加年级 2修改 3删除年级 4查询全部  0退出");
            choice = input.nextInt();
            switch (choice) {
                case 1:
                    System.out.println("请输入年级名");
                    String nj=input.next();
                    Grade ex=new Grade(null,nj);
                    int a=dao.add(ex);
                    System.out.println(a);
                    break;
                case 2:
                    System.out.println("请输入要修改的id");
                    int id1=input.nextInt();
                    System.out.println("请输入年级名");
                    String nj2=input.next();
                    Grade ex2=new Grade(id1,nj2);
                    int a2=dao.update(ex2);
                    System.out.println(a2);
                    break;
                case 3:
                    System.out.println("请输入要删除的id");
                    int id3=input.nextInt();
                    int a3=dao.del(id3);
                    System.out.println(a3);
                    if (a3==1){
                        System.out.println("删除成功");
                    }
                    break;
                case 4:
                    List<Grade> all = dao.all();
                    for (Grade g : all)
                        System.out.println(g);
                    break;
                case 5:
                   break;
                case 6:

                    break;
                case 0:
                    return;
            }
        }
    }

}
